<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单过程追踪列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input id="orderId" name="orderId"  type="hidden"  th:value="${orderId}" />
                    <div class="select-list">
                        <ul>
                            <!--<li>
                                <label>订单id：</label>
                                <input type="text" name="orderId"/>
                            </li>-->
                            <li>
                                <label>分类：</label>
                                <select name="logType" th:with="type=${@dict.getType('log_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addNewLog()" shiro:hasPermission="zsyh:serviceOrderLog:add">
                    <i class="fa fa-plus"></i> 添加新记录
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:serviceOrderLog:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:serviceOrderLog:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:serviceOrderLog:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:serviceOrderLog:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:serviceOrderLog:remove')}]];
        var logTypeDatas = [[${@dict.getType('log_type')}]];
        var prefix = ctx + "zsyh/serviceOrderLog";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "订单过程追踪",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '订单详细过程id',
                    visible: false
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '操作时间'
                },
                {
                    field: 'logType',
                    align: 'center',
                    title: '分类',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(logTypeDatas, value);
                    }
                },
                {
                    field: 'logContent',
                    title: '内容描述'
                },
                {
                    field: 'operatorId',
                    title: '平台操作人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.logType =='3'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editLog(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                }]
            };
            $.table.init(options);
        });
        
        function addNewLog() {
            layer.open({
                type: 2,
                area: ['800px', '300px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "新增工单记录",
                content: prefix + "/add/"+$("#orderId").val(),
                btnClose: 1,
                btn: ['确定','取消'],
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

        function editLog(id) {
            layer.open({
                type: 2,
                area: ['800px', '300px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "修改工单记录",
                content: prefix + "/edit/"+id,
                btnClose: 1,
                btn: ['确定','取消'],
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }
        
    </script>
</body>
</html>